# Contributor: fossdd <fossdd@pwned.life>
# Maintainer: fossdd <fossdd@pwned.life>
pkgname=dex-idp
pkgver=2.41.1
pkgrel=0
pkgdesc="OpenID Connect (OIDC) identity and OAuth 2.0 provider with pluggable connectors"
url="https://dexidp.io/"
arch="all"
license="Apache-2.0"
makedepends="go"
checkdepends="tzdata"
install="$pkgname.pre-install"
subpackages="$pkgname-bash-completion $pkgname-fish-completion $pkgname-openrc $pkgname-zsh-completion"
source="$pkgname-$pkgver.tar.gz::https://github.com/dexidp/dex/archive/refs/tags/v$pkgver.tar.gz
	dex-idp.initd
	"
builddir="$srcdir/dex-$pkgver"
options="net" # go dependencies

build() {
	make

	./bin/dex completion bash > $pkgname.bash
	./bin/dex completion fish > $pkgname.fish
	./bin/dex completion zsh > $pkgname.zsh
}

check() {
	make test
}

package() {
	install -Dvm755 bin/dex "$pkgdir"/usr/bin/dex-idp
	install -Dvm644 config.yaml.dist "$pkgdir"/etc/dex.yaml

	install -Dvm755 "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname

	install -Dvm644 $pkgname.bash \
		"$pkgdir"/usr/share/bash-completion/completions/$pkgname
	install -Dvm644 $pkgname.fish \
		"$pkgdir"/usr/share/fish/vendor_completions.d/$pkgname.fish
	install -Dvm644 $pkgname.zsh \
		"$pkgdir"/usr/share/zsh/site-functions/_$pkgname
}

sha512sums="
68d20eab9f1894461364a397d075eaf17a1551af16d35b5e2e52cf88bfca97c638fd7ef034c231f6e7c8bfc50077800ad68bf669e2b7c98fe6fd6c332266a1ca  dex-idp-2.41.1.tar.gz
a2ebd82788e09c2f6b7efff1d2115b692bcc7a68753a4ea1dd87ee93221f68f9c9ebf8caa81282f810b177479852353fb03274c0c97d7646197050568b642df3  dex-idp.initd
"
